<template>
	<div>
		<template>
			<div>
				<el-table :data="tableData" border style="width: 100%">
					<el-table-column prop="id" label="ID" width="150">
					</el-table-column>
					<el-table-column prop="casenumber" label="病例号" width="150">
					</el-table-column>
					<el-table-column prop="registid" label="挂号ID" width="150">
					</el-table-column>
					<el-table-column prop="readme" label="主诉" width="200">
					</el-table-column>
					<el-table-column prop="present" label="现病史" width="500">
					</el-table-column>
					<el-table-column prop="presenttreat" label="现病治疗情况" width="500">
					</el-table-column>
					<el-table-column prop="history" label="既往史" width="500">
					</el-table-column>
					<el-table-column prop="allergy" label="过敏史" width="350">
					</el-table-column>
					<el-table-column prop="physique" label="体格检查" width="250">
					</el-table-column>
					<el-table-column prop="proposal" label="检查建议" width="250">
					</el-table-column>
					<el-table-column prop="careful" label="注意事项" width="250">
					</el-table-column>
					<el-table-column prop="checkresult" label="检查结果" width="150">
					</el-table-column>
					<el-table-column prop="diagnosis" label="诊断意见" width="250">
					</el-table-column>
					<el-table-column prop="handling" label="处理意见" width="250">
					</el-table-column>
					<el-table-column prop="casestate" label="病例状态" width="100">
						<template slot-scope="scope">
							<el-tag size="medium" type="danger" v-if="scope.row.casestate===2">已提交</el-tag>
							<el-tag size="medium" type="primary" v-else-if="scope.row.casestate===1">暂存</el-tag>
							<el-tag size="medium" type="warning" v-else>诊毕</el-tag>
						</template>
					</el-table-column>
					<el-table-column label="操作" width="150">
						<template slot-scope="scope">
							<el-button type="primary" icon="el-icon-edit" size="mini" @click="ToEdit(scope.row.id)">
							</el-button>
						</template>
					</el-table-column>
				</el-table>
			</div>
		</template>
		<el-dialog title="确诊信息" :visible.sync="dialogFormVisible">
			<el-row>
				<el-col :span="10">
				</el-col>
				<el-col :span="5">
					<el-input placeholder="请输入患者挂号ID" v-model="ResultMess.registid">
						<el-button icon="el-icon-search"></el-button>
					</el-input>
				</el-col>
				<el-col :span="1">
					<el-button type="primary" @click="SearchByRegistId()">查询</el-button>
				</el-col>
			</el-row>
			<br />
			<el-table :data="ResultData" border style="width: 80%">
				<el-table-column prop="registid" label="挂号ID" width="100">
				</el-table-column>
				<el-table-column prop="name" label="项目名称" width="140">
				</el-table-column>
				<el-table-column prop="checkresult" label="检查结果" width="200">
				</el-table-column>
				<el-table-column prop="resulttime" label="结果时间" width="170">
				</el-table-column>
				<el-table-column prop="recordtype" label="记录类型" width="150">
				</el-table-column>
			</el-table>
			<br /><br /><br />
			<el-form>
				<el-form-item prop="id" label="ID" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.id" style="width: 700px;" :disabled="true"></el-input>
				</el-form-item>
				<el-form-item prop="casenumber" label="病例号" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.casenumber" style="width: 700px;" :disabled="true"></el-input>
				</el-form-item>
				<el-form-item prop="registid" label="挂号ID" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.registid" style="width: 700px;" :disabled="true"></el-input>
				</el-form-item>
				<el-form-item prop="readme" label="主诉" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.readme" style="width: 700px;" type="textarea" :disabled="true">
					</el-input>
				</el-form-item>
				<el-form-item prop="present" label="现病史" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.present" style="width: 700px;" type="textarea" :disabled="true">
					</el-input>
				</el-form-item>
				<el-form-item prop="presenttreat" label="现病治疗情况" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.presenttreat" style="width: 700px;" type="textarea"
						:disabled="true"></el-input>
				</el-form-item>
				<el-form-item prop="history" label="既往史" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.history" style="width: 700px;" type="textarea" :disabled="true">
					</el-input>
				</el-form-item>
				<el-form-item prop="allergy" label="过敏史" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.allergy" style="width: 700px;" type="textarea" :disabled="true">
					</el-input>
				</el-form-item>
				<el-form-item prop="physique" label="体格检查" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.physique" style="width: 700px;" type="textarea" :disabled="true">
					</el-input>
				</el-form-item>
				<el-form-item prop="proposal" label="检查建议" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.proposal" style="width: 700px;"></el-input>
				</el-form-item>
				<el-form-item prop="careful" label="注意事项" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.careful" style="width: 700px;"></el-input>
				</el-form-item>
				<el-form-item prop="checkresult" label="检查结果" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.checkresult" style="width: 700px;"></el-input>
				</el-form-item>
				<el-form-item prop="diagnosis" label="诊断意见" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.diagnosis" style="width: 700px;"></el-input>
				</el-form-item>
				<el-form-item prop="handling" label="处理意见" :label-width="formLabelWidth">
					<el-input v-model="DefiniteMess.handling" style="width: 700px;"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="danger" @click="ToDefinite()">确诊</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
	export default {
		name: "OutDiagnosis",
		data() {
			return {
				tableData: [],
				formLabelWidth: '100px',
				dialogTableVisible: false,
				dialogFormVisible: false,
				//确诊信息
				DefiniteMess: {},
				ResultData: {},
				ResultMess: {
					registid: ''
				}
			}
		},
		created() {
			let url = '/MedicalRecord/selectUndefinite'
			this.$axios.post(url)
				.then((resp) => {
					this.tableData = resp.data;
					console.log(this.tableData)
				})
		},

		methods: {
			ToEdit(id) {
				let url = '/MedicalRecord/selectById';
				let param = {};
				param.id = id;
				param = this.$qs.stringify(param);
				this.$axios.post(url, param)
					.then((resp) => {
						this.DefiniteMess = resp.data;
						// console.log(this.CheckMess);
					})
				this.dialogFormVisible = true;
			},
			SearchByRegistId() {
				let url = '/CheckApply/selectByRegistId'
				let param = this.$qs.stringify(this.ResultMess)
				this.$axios.post(url, param)
					.then((resp) => {
						// console.log('--this.med.id', resp.casenumber);
						this.ResultData = resp.data;
						console.log('this.tableData=', this.ResultData)
					})
			},
			FindUnDef() {
				let url = '/MedicalRecord/selectUndefinite'
				this.$axios.post(url)
					.then((resp) => {
						this.tableData = resp.data;
						console.log(this.tableData)
					})
			},
			ToDefinite() {
				let url = '/MedicalRecord/UpdateToDef';
				let param = this.$qs.stringify(this.DefiniteMess)
				// console.log("---param="+param)
				this.$axios.post(url, param)
					.then((resp) => {
						let i = resp.data;
						if (i > 0) {
							return this.$message.success("确诊成功!");
						} else {
							return this.$message.error('确诊失败!')
						}
					})
					.catch((err) => {
						console.log('error=', err)
					})
				// this.dialogFormVisible = false;
				this.dialogFormVisible = false;
				this.FindUnDef();
				window.location.reload()
			}
		},
	}
</script>

<style scoped>

</style>
